import {createSlice} from "@reduxjs/toolkit";

const stuSlice = createSlice({
    name: 'stu',
    initialState: {
        name: '孙悟空',
        age: 18,
        gender: '男',
        address: '花果山'
    }, reducers: {
        //指定state 的各种操作
        setName(state, action) {
            console.log(action);
            state.name = action.payload.name
        },
        setAge(state, action) {
            state.age = 28
        }
    }
})
export const {setName, setAge} = stuSlice.actions
export const { reducer:stuReducer}=stuSlice